<template>
    <div class="header">
        <div class="l-content">
            <el-button icon="el-icon-menu" circle @click="handleMenu"></el-button>
            <!-- 面包屑 -->
            <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: item.path }" v-for="item in tabList" :key="item.path">{{ item.label
                }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="r-content">
            <el-dropdown @command="handleCommand">
                <span class="el-dropdown-link">
                    <img src="../assets/images/user-icon.jpg" alt="" class="user">
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>个人中心</el-dropdown-item>
                    <el-dropdown-item command="cancel">退出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
</template>

<script>
import Cookie from "js-cookie";
import { mapMutations, mapState } from "vuex";
export default {
    data() {
        return {

        }
    },
    methods: {
        ...mapMutations("tab", ["collapseMenu"]),
        handleMenu() {
            this.collapseMenu()
        },
        handleCommand(command) {
            if (command === 'cancel') {
                // 清楚cookie中的token
                Cookie.remove("token")
                // 清除cookie中的menu
                Cookie.remove("menu")
                // 跳转到登录页面
                this.$router.push("/login")
            }
        }
    },
    computed: {
        ...mapState('tab', ['tabList'])
    }
}
</script>

<style lang="less" scoped>
.header {
    height: 60px;
    background-color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;


    .user {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }

    .l-content {
        display: flex;
        align-items: center;

        .el-breadcrumb {
            margin-left: 20px;
        }



        /deep/.el-breadcrumb__item {
            .el-breadcrumb__inner {
                color: #666;
            }

            &:last-of-type {
                .el-breadcrumb__inner {
                    color: #fff;
                }
            }
        }
    }
}
</style>